//
//  WBEmoticonButton.swift
//  weibo
//
//  Created by 胡古古 on 2017/6/16.
//  Copyright © 2017年 hugugu. All rights reserved.
//

import UIKit

class WBEmoticonButton: UIButton {

    var emoticon: WBEmoticon? {
        
        didSet {
            
            
            guard let currEmoticon = emoticon else {
                
                return
            }
            
            if currEmoticon.type == "0" {
                
                let image = UIImage(named: currEmoticon.path!, in: WBEmoticonTools.sharedTools.emoticonBundle, compatibleWith: nil)
                
                self.setImage(image, for: .normal)
                
                self.setTitle(nil, for: .normal)
            } else {
                
                let emoji = (currEmoticon.code! as NSString).emoji()
                
                self.setTitle(emoji, for: .normal)
                
                self.setImage(nil, for: .normal)
                
            }

            
            
            
        }
        
        
    }
    
    
}
